<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');
// load base class if needed
require_once( APPPATH . 'controllers/base/OperatorBase.php' );

class operatorwelcome extends ApplicationBase {

    // constructor
    public function __construct() {
        parent::__construct();
        // load model
        // load library
        // load helpers
    }

    // welcome administrator
    public function index() {
        // set page rules (all admin)
        // $this->_set_page_rule("R");
        // set template content
        $this->smarty->assign("template_content", "home/admin/welcome.html");

        // output
        parent::display();
    }

    public function test() {
        $nomor_polisi = "029.1.2.2.010214.1.3.60";
        /*
         *  print out
         */

        // load library
        $this->load->library('tcpdf');
        // data
        // page setting
        $this->tcpdf->SetPrintHeader(false);
        $this->tcpdf->SetPrintFooter(false);
        $this->tcpdf->SetDisplayMode('real');
        $this->tcpdf->SetMargins(5, 5, 5, false);
        $this->tcpdf->SetFont('times', '', 9, '');
        $this->tcpdf->AddPage('P', 'A4');

        // barcode
        $style = array(
            'position' => 'S',
            'align' => 'C',
            'stretch' => true,
            'fitwidth' => true,
            'cellfitalign' => 'C',
            'border' => false,
            'padding' => 2,
            'fgcolor' => array(0, 0, 0),
            'bgcolor' => false, //array(255,255,255),
            'text' => true,
            'font' => 'times',
            'fontsize' => 50,
            'stretchtext' => 40
        );
        $params = $this->tcpdf->serializeTCPDFtagParameters(array($nomor_polisi, 'C39', '', '', '', 16, 0.8, $style, 'M'));

        $html = '';
        // html content

        for ($i = 0; $i < 20; $i++) {

            $html .= '<table border="0" cellpadding="0" cellspacing="0" width="200mm" style="float:left; position:relative; margin:5mm;">';
            $html .= '  <tr>';
            $html .= '      <td align="center" height="8mm" width="98mm" border="1">';
            $html .= '         <span style="color:red;font-weight:bold;">';
            $html .= '            INVENTARIS';
            $html .= '            <br />';
            $html .= '            STMIK AMIKOM YOGYAKARTA';
            $html .= '         </span>';
            $html .= '      </td>';

            $html .= '      <td rowspan="2" width="4mm">';
            $html .= '      </td>';

            $html .= '      <td align="center" height="8mm" width="98mm" border="1">';
            $html .= '         <span style="color:red;font-weight:bold;">';
            $html .= '            INVENTARIS';
            $html .= '            <br />';
            $html .= '            STMIK AMIKOM YOGYAKARTA';
            $html .= '         </span>';
            $html .= '      </td>';
            $html .= '  </tr>';

            $html .= '  <tr>';
            $html .= '      <td align="center" height="15mm" border="1">';
            $html .= '      <tcpdf method="write1DBarcode" params="' . $params . '"/>';
            $html .= '      </td>';
            $html .= '      <td align="center" height="15mm" border="1">';
            $html .= '      <tcpdf method="write1DBarcode" params="' . $params . '"/>';
            $html .= '      </td>';
            $html .= '  </tr>';

            $html .= '</table>';

            $html .= '<br />';
            $html .= '&nbsp;';
        }

        //echo $html;
        // write
        $this->tcpdf->writeHTML($html, true, 0, true, 0, '');
        $this->tcpdf->Output($nomor_polisi . '.pdf', 'D');
    }

}
